package com.pri.chat.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.netease.nim.uikit.net.SharedHelper;
import com.netease.nim.uikit.net.entity.MemberBean;
import com.pri.chat.R;
import com.pri.chat.utils.GlideUtil;
import com.pri.chat.view.ImageViewPlus;

import java.util.List;

/**
 * 描述：添加类的描述
 *
 * @author
 * @time 2020/4/30
 */
public class HmdMemberAdapter extends BaseQuickAdapter<MemberBean, BaseViewHolder> {

    public HmdMemberAdapter(int layoutResId, @Nullable List<MemberBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MemberBean item) {
        helper.addOnClickListener(R.id.tv_say_hello);
        helper.setText(R.id.age,item.getAge());
        helper.setText(R.id.city, SharedHelper.readValueByKeyForString(mContext,"city"));
        ImageView sex = helper.getView(R.id.sex);
        View sex_age_bg = helper.getView(R.id.sex_age_bg);

        if("男".equals(item.getSex())){
            sex.setImageResource(R.mipmap.man);
            sex_age_bg.setBackgroundResource(R.drawable.btn_sex_man);
        }else{
            sex.setImageResource(R.mipmap.woman);
            sex_age_bg.setBackgroundResource(R.drawable.btn_sex_woman);
        }
        helper.setText(R.id.age,item.getAge()+"");


        TextView vip_bg = helper.getView(R.id.vip_bg);
        if("是".equals(item.getMemberLevel())){
            vip_bg.setText("VIP");
            vip_bg.setVisibility(View.VISIBLE);
        }else{
            vip_bg.setVisibility(View.GONE);
        }

        TextView vip_super_bg = helper.getView(R.id.vip_super_bg);
        if("是".equals(item.getIsSupperVip())){
            vip_super_bg.setText("SVIP");
            vip_super_bg.setVisibility(View.VISIBLE);
        }else{
            vip_super_bg.setVisibility(View.GONE);
        }
        if("1".equals(item.getRzStatus())){
            helper.setVisible(R.id.tv_real_verify,true);
        }else{
            helper.setVisible(R.id.tv_real_verify,false);
        }
        helper.setText(R.id.tv_friends_name,item.getName());
        GlideUtil.getInstance().loadHeadImg(mContext,(ImageViewPlus)helper.getView(R.id.iv_logo),item.getHeadPic());
    }
}
